using Commons.Daos.Users;
using Commons.Models.Users;
using Commons.Preferences;
using System.Collections.Generic;

namespace Commons.Services.Users
{
	public class UserService : IUserService
	{
		public IUserDao UserDao { protected get; set; }

        public List<User> GetAllUsers()
        {
            return new List<User>(UserDao.GetAll());
        }

		public User GetLoggedUser()
		{
			return UserDao.Get(GamePrefs.UserId);
		}

		public void UpdateUser(User user)
		{
			UserDao.Update(user);
		}

        public User CreateUser(string userName, string password)
        {
            long lastIndex = UserDao.GetLastIndex();
            User user = new User(++lastIndex, userName, password);
            UserDao.Insert(user);
            return user;
        }

    }
}
